package des.wangku.operate.standard.subengineering.textContent;

import java.util.Properties;

import des.wangku.operate.standard.utls.UtilsProperties;

/**
 * 替换文本内容
 * 
 * @author Sunjian
 * @version 1.0
 * @since jdk1.8
 */
public class TextReplace {
	/**
	 * 
	 * @param content String
	 * @param propfiles String[]
	 * @return String
	 */
	public static final String replaceFromProperties(String content,String... propfiles) {
		if(content==null||content.length()==0)return content;
		for(String pfile:propfiles) {
			Properties properties = UtilsProperties.loadProperties( pfile);
			if(properties==null)continue;
	        for (String key : properties.stringPropertyNames()) {
	        	if(key==null||key.length()==0)continue;
	        	String right= properties.getProperty(key);
	        	String[] arr=key.split("\\|");
	        	for(String f:arr) {
	        		System.out.println("find["+f+"] to "+right);
		        	content =content.replace(f.trim(), right);
	        	}
	        }
		}
		return content;
	}
}
